package com.example.newproject_overseas.Screen.Main


import android.util.Log
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.text.ClickableText
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowForward
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.BlurredEdgeTreatment.Companion.Rectangle
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PaintingStyle.Companion.Stroke
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight.Companion.Bold
import androidx.compose.ui.text.font.FontWeight.Companion.Medium
import androidx.compose.ui.text.font.FontWeight.Companion.Normal
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.example.newproject_overseas.R
import com.example.newproject_overseas.ViewModel.LoginViewModel
import com.example.newproject_overseas.compositionLocal.LocalUserViewModel

@Composable
fun My() {
    //将 注册好的数据 带过来 并且赋给名称LoginVm
    var loginVM = LocalUserViewModel.current

    Column(
        modifier = Modifier
            .fillMaxSize()
            .background(
                brush = Brush.verticalGradient(
                    colors = listOf(Color(0xffFFBE01), Color(0xffFFFCF5), Color(0xffFFFFFF)),
                    startY = 0f,
                    endY = Float.POSITIVE_INFINITY
                )
            )
    ) {
        //第一个
        Row(modifier = Modifier.padding(start = 7.5.dp, top = 12.dp)) {
            Text(
                text = "Personal center",
                fontSize = 22.5.sp,
                color = Color.White,
                fontWeight = Bold
            )
        }
        //第二个
        Row(
            modifier = Modifier
                .fillMaxWidth()
                .padding(top = 8.dp)
        ) {
            Image(
                painter = painterResource(id = R.drawable.my_touxiang),
                contentDescription = null,
                modifier = Modifier
                    .size(67.dp)
                    .padding(start = 7.5.dp)
            )
            Column(modifier = Modifier.padding(start = 15.dp, top = 5.dp)) {
                Text(
                    text = "HELLO USER",
                    fontSize = 27.5.sp,
                    fontWeight = Medium,
                    color = Color(0xffFFFFFF)
                )
                Text(
                    text = "Safe and reliable loan app",
                    fontSize = 12.5.sp,
                    fontWeight = Normal,
                    color = Color(0xffFFFFFF)
                )
            }
        }
        //第三个
        Row(
            modifier = Modifier
                .fillMaxWidth()
                .padding(top = 20.dp)
                .padding(horizontal = 7.5.dp)
                .background(color = Color(0xffFFFFFF))
        ) {
            Row(
                modifier = Modifier
                    .weight(1f)
                    .fillMaxWidth()
            ) {
                Column(
                    modifier = Modifier
                        .weight(1f)
                        .clickable {
                            Log.i("----", "我点击的我的钱包")
                        },
                    horizontalAlignment = Alignment.CenterHorizontally
                ) {
                    Image(
                        painter = painterResource(id = R.drawable.my_qianbao),
                        contentDescription = null,
                        modifier = Modifier
                            .padding(top = 11.dp)
                            .size(34.12.dp)

                    )
                    Text(
                        text = "My loan",
                        textAlign = TextAlign.Center,
                        fontSize = 17.5.sp,
                        fontWeight = Medium,
                        color = Color(0xff4E4B4B),
                        modifier = Modifier.padding(bottom = 11.dp, top = 11.dp)
                    )
                }
                Column(
                    modifier = Modifier.padding(top = 10.dp),
                    verticalArrangement = Arrangement.Center,
                ) {
                    Image(
                        painter = painterResource(id = R.drawable.my_third_border),
                        contentDescription = null
                    )
                }
                Column(
                    modifier = Modifier
                        .weight(1f)
                        .clickable {
                            Log.i("----", "我点击的关于我们")
                        },
                    horizontalAlignment = Alignment.CenterHorizontally
                ) {
                    Image(
                        painter = painterResource(id = R.drawable.my_aboutus),
                        contentDescription = null,
                        modifier = Modifier
                            .padding(top = 11.dp)
                            .size(34.12.dp)
                    )
                    Text(
                        text = "About us",
                        textAlign = TextAlign.Center,
                        fontSize = 17.5.sp,
                        fontWeight = Medium,
                        color = Color(0xff4E4B4B),
                        modifier = Modifier.padding(vertical = 11.dp)

                    )
                }
            }
        }
        //第四个
        Row(
            modifier = Modifier
                .fillMaxWidth()
                .padding(horizontal = 7.5.dp, vertical = 20.dp)
                .background(color = Color(0xffffffff))
                .clickable { Log.i("---", "我点了security") },
            verticalAlignment = Alignment.CenterVertically

        ) {
            Row(
                modifier = Modifier.padding(vertical = 10.dp),
                verticalAlignment = Alignment.CenterVertically
            ) {
                Image(
                    painter = painterResource(id = R.drawable.security),
                    contentDescription = null,
                    modifier = Modifier
                        .padding(start = 14.dp)
                        .size(40.71.dp)
                )
                Text(
                    text = "Security Protocol",
                    color = Color(0xff5F5F5F),
                    fontSize = 17.5.sp,
                    modifier = Modifier.padding(start = 12.dp)

                )
                Row(
                    modifier = Modifier
                        .weight(1f)
                        .padding(end = 20.dp),
                    horizontalArrangement = Arrangement.End
                ) {
                    Icon(imageVector = Icons.Default.ArrowForward, contentDescription = null)
                }
            }
        }
        //第五个
        Row(
            modifier = Modifier
                .fillMaxWidth()
                .padding(horizontal = 7.5.dp)
                .padding(bottom = 20.dp)
                .background(color = Color(0xffffffff))
                .clickable { Log.i("--", "我点击了人工客服") },
            verticalAlignment = Alignment.CenterVertically

        ) {
            Row(
                modifier = Modifier.padding(vertical = 10.dp),
                verticalAlignment = Alignment.CenterVertically
            ) {
                Image(
                    painter = painterResource(id = R.drawable.my_erji),
                    contentDescription = null,
                    modifier = Modifier
                        .padding(start = 14.dp)
                        .size(40.71.dp)

                )
                Text(
                    text = "Security Protocol",
                    color = Color(0xff5F5F5F),
                    fontSize = 17.5.sp,
                    modifier = Modifier.padding(start = 12.dp)

                )
                Row(
                    modifier = Modifier
                        .weight(1f)
                        .padding(end = 20.dp),
                    horizontalArrangement = Arrangement.End
                ) {
                    Icon(imageVector = Icons.Default.ArrowForward, contentDescription = null)
                }
            }
        }
        //按钮
        Row(modifier = Modifier) {
            Button(
                onClick = {},
                colors = ButtonDefaults.buttonColors(
                    containerColor = Color(0xffFFBE01),
                    contentColor = Color.White
                ),
                modifier = Modifier
                    .padding(horizontal = 35.dp)
                    .height(46.5.dp),
                shape = RectangleShape //设置形状为矩形
            ) {
                Row(verticalAlignment = Alignment.CenterVertically) {
                    Text(
                        text = "LOG OUT",
                        modifier = Modifier.weight(1f),
                        textAlign = TextAlign.Center,
                        fontSize = 20.5.sp,
                    )
                }
            }
        }
        Spacer(modifier = Modifier.height(40.dp))
        //最下面的图片
        Box(
            modifier = Modifier
                .fillMaxWidth()
                .padding(horizontal = 7.5.dp)

        ) {
            Image(
                painter = painterResource(id = R.drawable.my_last),
                contentDescription = null,
                contentScale = ContentScale.FillBounds,
                modifier = Modifier
                    .fillMaxWidth()
                    .height(122.dp)
            )
            Column(modifier = Modifier.fillMaxWidth().padding(end = 7.5.dp)) {
                Row(
                    modifier = Modifier
                        .padding(top = 41.5.dp)
                        .fillMaxWidth(),
                    horizontalArrangement = Arrangement.End
                ) {
                    Text(
                        text = "One-click lending, lightning arrival",
                        color = Color(0xff000000),
                        fontSize = 12.5.sp,
                    )
                }
                Row(
                    modifier = Modifier
                        .padding(top = 11.5.dp, end = 4.dp)
                        .fillMaxWidth(),

                    horizontalArrangement = Arrangement.End
                ) {
                    Text(
                        text =loginVM.my_last,
                        color = Color(0xff000000),
                        fontSize = 12.5.sp,
                    )
                }
            }
        }
    }
}




